#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 2e5+10;

int cnt[28],n;
ll ans;
char s[N];

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	scanf("%s",s+1); n = strlen(s+1);
	for(int i = n;i >= 1;i--){
		cnt[s[i]-'a']++;
		if(i < n && s[i+1] == s[i]){
			ans += n - i + 1 - cnt[s[i]-'a'];
			memset(cnt,0,sizeof(cnt)); cnt[s[i]-'a'] = n - i + 1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

